cmake_minimum_required(VERSION 3.5)
project(vikit_ros)

# 编译类型
set(CMAKE_BUILD_TYPE Release) # Release, RelWithDebInfo
set(CMAKE_VERBOSE_MAKEFILE OFF)

# 编译选项
set(CMAKE_CXX_FLAGS "-Wall -D_LINUX -D_REENTRANT -march=native -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unknown-pragmas")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g")
if(CMAKE_COMPILER_IS_GNUCC)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
else()
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
endif()

# 依赖
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(vikit_common REQUIRED)  # 确认有 ROS2 版本
find_package(visualization_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Eigen3 REQUIRED)
set(Sophus_DIR /home/alex/unitree/gazebo_sim/src/rpg_vikit/3rdparty/Sophus/dist/share/sophus/cmake)
find_package(Sophus REQUIRED)

# 头文件路径
include_directories(
  include
  ${EIGEN3_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
  ${Sophus_INCLUDE_DIRS}
)

# 源文件
set(SOURCEFILES
  src/output_helper.cpp
)

# 库
add_library(${PROJECT_NAME} SHARED ${SOURCEFILES})
ament_target_dependencies(${PROJECT_NAME}
  rclcpp
  visualization_msgs
  tf2_ros
  vikit_common
  OpenCV
  Eigen3
  Sophus
)

# 安装
install(
  TARGETS ${PROJECT_NAME}
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
)

install(
  DIRECTORY include/
  DESTINATION include
)

# 导出依赖
ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})
ament_export_dependencies(
  rclcpp
  visualization_msgs
  tf2_ros
  vikit_common
  OpenCV
  Eigen3
  Sophus
)

ament_package()
